/*

NOTES

-Reads in the stata dataset named "CPS_v4". 
-Collapses the data set into state-year averages and sample sizes conditional on occupation group
-Saves the data into a stata data set and then exports it to an excel spreadsheet. 
-The saved data sets can be found in cd "$data"
-wage_CC_data corresponds to the state-year averages of childcare workers while
wage_CCPSKT_data corresponds to the state-year averages of childcare, preschool,
and kindergarten teachers.

*/


clear
cls


use "$temp\CPS_v4.dta"


foreach w of varlist earnwta {
foreach x of varlist CC CCPSKT {

di as text "STATE-YEAR OBSERVATION FOR `x'"
collapse (count) N_`x' = hwage (mean) HW_`x' = hwage if `x' == 1 [aw=`w'], by(state year)
egen state_year = concat(year state)

save "$temp\wage_`x'_data.dta", replace
export excel using "$temp\wage_`x'_data.xls", firstrow(variables) replace
clear 
cls

use "$temp\CPS_v4.dta"

}
}


erase "$temp\CPS_E5.dta"
erase "$temp\CPS_v4.dta"






